/**
 * @ProjectName:exam
 * @FileName: SchoolBus.java
 * @PackageName: edu.xpu.project.vehicle.entity
 * @Company:北京有生博大软件有限公司（西安分公司）
 * @Copyright (c) 2017,RiseSoft  All Rights Reserved.
 * @date 2017年4月29日 下午12:32:21
 */
package edu.xpu.project.vehicle.entity;

import java.io.Serializable;
import java.util.Date;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.codehaus.jackson.annotate.JsonIgnoreProperties;

import edu.xpu.project.log.entity.SchoolBusLog;
import edu.xpu.project.user.entity.DriverEntity;

/**
 * @ClassName: SchoolBus.java
 * @Description: 校车关系
 *
 * @author liukang
 * @date 2017年4月29日 下午12:32:21
 * @version 
 * @since JDK 1.6
 */
@Entity(name="SchoolBus")
@Table(name="SCHOOL_BUS")
@JsonIgnoreProperties({"driverEntity", "busLogs"})
public class SchoolBus implements Serializable {

	private static final long serialVersionUID = 5536035185827817965L;
	
	@Id
	@GeneratedValue(strategy=GenerationType.IDENTITY)
	private Long id;
	
	private String name;
	
	private String schoolNo;		//校车编号
	
	private Integer seatTotal;		//座位总数
	
	/**
	 * 0: 新加校车(不可使用)
	 * 1: 可用, 空闲
	 * 2: 待发车
	 * 3: 发车中
	 * 4: 维修(不可用)
	 */
	private Integer status;			//校车状态
	
	/*
	 * 0: 未指定
	 * 1: 金花校区
	 * 2: 临潼校区
	 */
	private Integer localStatus;		//位置信息
	
	@ManyToOne(fetch=FetchType.EAGER, optional=true)
	@JoinColumn(name="driver_id")
	private DriverEntity driverEntity;
	
	/*@ManyToOne(optional=true)
	@JoinColumn(name="assign_id")
	private AssignBusRecord assignBusRecord;*/
	
	/*     系统属性     */
	private Date createDate;
	private Long createPersonId;
	private String createPersonName;
	
	@OneToMany(mappedBy="schoolBus", fetch=FetchType.EAGER, cascade={CascadeType.REMOVE})
	private Set<SchoolBusLog> busLogs;
	
	public int getBusLogNum() {
		if (busLogs != null) {
			return busLogs.size();
		}
		return 0;
	}
	
	public Long getId() {
		return id;
	}
	public void setId(Long id) {
		this.id = id;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getSchoolNo() {
		return schoolNo;
	}
	public void setSchoolNo(String schoolNo) {
		this.schoolNo = schoolNo;
	}
	public Integer getSeatTotal() {
		return seatTotal;
	}
	public void setSeatTotal(Integer seatTotal) {
		this.seatTotal = seatTotal;
	}
	public Integer getStatus() {
		return status;
	}
	public void setStatus(Integer status) {
		this.status = status;
	}
	public Date getCreateDate() {
		return createDate;
	}
	public void setCreateDate(Date createDate) {
		this.createDate = createDate;
	}
	public Long getCreatePersonId() {
		return createPersonId;
	}
	public void setCreatePersonId(Long createPersonId) {
		this.createPersonId = createPersonId;
	}
	public String getCreatePersonName() {
		return createPersonName;
	}
	public void setCreatePersonName(String createPersonName) {
		this.createPersonName = createPersonName;
	}
	public DriverEntity getDriverEntity() {
		return driverEntity;
	}
	public void setDriverEntity(DriverEntity driverEntity) {
		this.driverEntity = driverEntity;
	}
	public Integer getLocalStatus() {
		return localStatus;
	}
	public void setLocalStatus(Integer localStatus) {
		this.localStatus = localStatus;
	}
	/*public AssignBusRecord getAssignBusRecord() {
		return assignBusRecord;
	}
	public void setAssignBusRecord(AssignBusRecord assignBusRecord) {
		this.assignBusRecord = assignBusRecord;
	}*/
	public Set<SchoolBusLog> getBusLogs() {
		return busLogs;
	}
	public void setBusLogs(Set<SchoolBusLog> busLogs) {
		this.busLogs = busLogs;
	}
	
}

